package ws

import (
	"encoding/json"

	"github.com/gofiber/websocket/v2"
)

func SendWebsocketInfo(conn *Conn, data *SendInfo) ([]byte, error) {
	sendInfo, err := json.Marshal(data)
	if err != nil {
		return nil, err
	}
	if conn.Conn != nil {
		return sendInfo, conn.Conn.WriteMessage(websocket.TextMessage, sendInfo)
	} else {
		return nil, nil
	}
}
